package com.kaikai.edu.controller;

import com.kaikai.commonutils.R;
import com.kaikai.edu.entity.ao.EduLoginAO;
import com.kaikai.edu.service.EduLoginService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@CrossOrigin
@RestController
@RequestMapping("eduservice/user")
public class EduLoginController {

    @Autowired
    private EduLoginService loginService;

    /**
     * @param loginAo
     * @return com.kaikai.commonutils.R
     * @Author yujiankai
     * @Description 登录
     * @date 2021/11/29 10:56
     */
    @ApiOperation(value = "登录")
    @PostMapping("login")
    public R login(@RequestBody EduLoginAO loginAo){
        //需要返回一个token
        return loginService.login(loginAo);
    }
    @RequestMapping("info")
    public R info(){
        //name, avatar
        return R.ok().data("name","admin").data("avatar","https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3355464299,584008140&fm=26&gp=0.jpg");
    }

    /**
     * @param request
	 * @param response
     * @return java.lang.Boolean
     * @Author yujiankai
     * @Description 退出登录
     * @date 2021/11/29 11:01
     */
    @ApiOperation(value = "退出登录")
    @GetMapping("logout")
    public R logout(HttpServletRequest request, HttpServletResponse response){
        return loginService.logout(request);
    }

}
